/*
 * Javlov - a Java toolkit for reinforcement learning with multi-agent support.
 * 
 * Copyright (c) 2009 Matthijs Snel
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.javlov.world.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import net.javlov.world.grid.GridCell;
import net.javlov.world.grid.IGridWorld;
import net.javlov.world.phys2d.Phys2DGridWorld;

public class GridWorldView extends WorldView {

	private static final long serialVersionUID = -7869693675325253384L;

	public GridWorldView(IGridWorld w) {
		super(w);
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.transform(getScaleTransform());
		GridCell[][] cells = ((IGridWorld) model).getGrid().getCells();
		for(int h = 0; h < cells[0].length; h++)
    		for(int w = 0; w < cells.length; w++) {
    			g2d.setColor(Color.yellow);
    			g2d.draw(cells[w][h]);
    			g2d.setColor(Color.black);
    			g2d.drawString(""+cells[w][h].getOccupiers().size(), (int)cells[w][h].x + 5, (int)cells[w][h].y + 15);
    		}
		g2d.setTransform(getOriginalTransform());
	}
}
